package com.dragon.repository.domain.dto;

import com.dragon.repository.entity.Dictsort;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.dragon.common.util.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DictsortDTO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "分类名称")
    private String dictsortName;

    @ApiModelProperty(value = "字典编码")
    private String dictsortCode;

    @ApiModelProperty(value = "上级分类")
    private Integer pid;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;


    public DictsortDTO() {}

    public DictsortDTO(Dictsort entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static DictsortDTO convert(Dictsort entity) {
        return new DictsortDTO(entity);
    }

    public static List<DictsortDTO> convertList(List<Dictsort> list) {
        List<DictsortDTO> resultList = new ArrayList<>();
        for (Dictsort entity : list) {
            resultList.add(new DictsortDTO(entity));
        }
        return resultList;
    }}
